<template>
	<view class="bankinfo">
		<view class="bankinfo-name">
			<view class="bankinfo-nameL">
				姓名:
			</view>
			<input class="binkinfo-input" v-model="name" placeholder="请输入姓名" type="text"  />
		</view>
		<view class="bankinfo-name">
			<view class="bankinfo-nameL">
				手机号:
			</view>
			<input class="binkinfo-input" v-model="phone" placeholder="请输入手机号码" type="number"  />
		</view>
		<view class="bankinfo-name">
			<view class="bankinfo-nameL">
				银行名称:
			</view>
			<input class="binkinfo-input" v-model="bankName" placeholder="请输入银行名称" type="number"  />
		</view>
		<view class="bankinfo-name">
			<view class="bankinfo-nameL">
				银行卡号:
			</view>
			<input class="binkinfo-input" v-model="bankNum" placeholder="请输入银行卡号" type="number"  />
		</view>
		<view class="bankinfo-name">
			<view class="bankinfo-nameL">
				银行地址:
			</view>
			<input class="binkinfo-input1"  v-model="bankAddress" placeholder="请输入银行地址" type="number"  />
		</view>
		<view class="submit-bankinfo" @click="addbank">
			保存
		</view>
	</view>
</template>

<script>
	let that
	import {mapGetters} from "vuex"
	import {toLogin} from "@/libs/login.js"
	import tool from "@/extend/tool.js"
	
	import {
		addBankInfo,
		getBankInfo
	} from '@/api/user.js';
	export default{
		data(){
			return {
				uid: 0,
				userInfo: {},
				name:'',
				phone:'',
				bankName:'',
				bankNum:'',
				bankAddress:'',
			}
		},
		computed:{
			...mapGetters(['isLogin'])
		},
		onLoad(opts){
			// that = this
			// this.uid = parseInt(opts.uid || 0)
			// this.getInitDataUserInfo();
			// this.getProductList();
			this.getBank()
		},
		methods:{
			getBank(){
				getBankInfo().then(res=>{
					console.log(res);
					// this.CashList = res.data
					this.name = res.data.info.name
					this.phone = res.data.info.phone
					this.bankName = res.data.info.bank_name
					this.bankNum = res.data.info.bank_num
					this.bankAddress = res.data.info.bank_address
				}).catch(err => {
									uni.hideLoading();
									uni.showToast({
										title: err,
										icon: 'none',
										duration: 2000
									});
								});
			},
			addbank(){
				addBankInfo({
						name: this.name,
						phone: this.phone,
						bank_name: this.bankName,
						bank_num: this.bankNum,
						bank_address: this.bankAddress,
					}).then(res=>{
						console.log(res);
						uni.showToast({
							title: "保存成功",
							icon: 'success',
							duration: 2000
						});

						// this.CashList = res.data
					}).catch(err => {
									uni.hideLoading();
									uni.showToast({
										title: err,
										icon: 'none',
										duration: 2000
									});
								});
			},

		},
		onReachBottom() {
			this.getProductList();
		}
	}
</script>

<style lang="scss" scoped>
	@mixin flex {
		display: flex;
	}
	.bankinfo{
	.bankinfo-name{
		height: 120rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 20rpx;
		width: 96%;
		margin: 0 auto;
		padding: 0 20rpx;
		border-bottom: 1rpx solid #ccc;
		line-height: 120rpx;
		.bankinfo-nameL{
			font-size: 32rpx;
			color: #000;
			
		}
		.binkinfo-input{
			width: 60%;
			text-align: right;
			font-size: 28rpx;
			color: #333;
		}
		.binkinfo-input1{
			width: 60%;
			text-align: right;
			font-size: 28rpx;
			color: #333;
		}
	}
	.submit-bankinfo{
		width: 500rpx;
		height: 100rpx;
		background-color: #2678FF;
		font-size: 30rpx;
		color: #fff;
		line-height: 100rpx;
		border-radius: 50rpx;
		margin: 100rpx auto;
		text-align: center;
		
	}
	}

</style>